<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <!-- 
        replaceChild(要替换的成的结点，被替换的结点)   替换结点
        cloneNode(括号内需要写布尔型 )  复制结点   
        removeChild()  删除结点

     -->

    <ul>
        <li>trump1</li>
        <li>trump2</li>
        <li>trump3</li>
        <li>trump4</li>
        <li>trump5</li>
    </ul>


    <script>

        var ul=document.querySelector("ul")
        var trump2=ul.children[1]    //先获取要修改的结点
        var li=document.createElement('li')   
        var liText=document.createTextNode('biden')  
        li.appendChild(liText)    
        ul.replaceChild(li,trump2)   //replaceChild(要替换的成的结点，被替换的结点)


        var copyLi=trump2.cloneNode(true);  //括号内需要写布尔型  
        ul.appendChild(copyLi)

        var li4=ul.children[3]  //下标为3
        ul.removeChild(li4)
    </script>
    
</body>
</html>